'use strict';
const { defineConfig } = require('@vue/cli-service');
const webpack = require('webpack'); //添加webpack
const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir);
}
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  publicPath: './',
  outputDir: 'face',
  devServer: {
    host: '0.0.0.0',
    port: process.env.port,
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        ws: true,
        changeOrigin: true,
        target: process.env.VUE_APP_PROXY_TARGET,
        router: process.env.VUE_APP_PROXY_TARGET,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      }
    },
    client: {
      overlay: false
    }
  },
  configureWebpack: {
    // plugins: [new BundleAnalyzerPlugin()],
    plugins: [
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        jquery: 'jquery',
        'window.jQuery': 'jquery'
      })
    ],
    resolve: {
      alias: {
        '@': resolve('src')
      },
      fallback: {
        path: require.resolve('path-browserify')
      }
    },
    module: {
      rules: [
        {
          test: /.js$/,
          include: path.resolve('src'),
          exclude: /node_modules/,
          use: [
            'thread-loader', // 将后续 loader 放在 worker 池中执行耗时的 loader （例如 babel-loader）
            'babel-loader'
          ]
        }
      ]
    }
  }
});
